outfile.write("Usage: %s [OPTIONS] <file> [ARGS]\n\nMeta-options:\n--help Display this help then exit.\n--version Output version information then exit.\n\nOtherwise, exactly one of the following three options must be given:\n-t, --trace Print each line to sys.stdout before it is executed.\n-c, --count Count the number of times each line is executed\n and write the counts to <module>.cover for each\n module executed, in the module's directory.\n See also `--coverdir', `--file', `--no-report' below.\n-l, --listfuncs Keep track of which functions are executed at least\n once and write the results to sys.stdout after the\n program exits.\n-T, --trackcalls Keep track of caller/called pairs and write the\n results to sys.stdout after the program exits.\n-r, --report Generate a report from a counts file; do not execute\n any code. `--file' must specify the results file to\n read, which must have been created in a previous run\n with `--count --file=FILE'.\n\nModifiers:\n-f, --file=<file> File to accumulate counts over several runs.\n-R, --no-report Do not generate the coverage report files.\n Useful if you want to accumulate over several runs.\n-C, --coverdir=<dir> Directory where the report files. The coverage\n report for <package>.<module> is written to file\n <dir>/<package>/<module>.cover.\n-m, --missing Annotate executable lines that were not executed\n with '>>>>>> '.\n-s, --summary Write a brief summary on stdout for each file.\n (Can only be used with --count or --report.)\n\nFilters, may be repeated multiple times:\n--ignore-module=<mod> Ignore the given module and its submodules\n (if it is a package).\n--ignore-dir=<dir> Ignore files in the given directory (multiple\n directories can be joined by os.pathsep).\n" % sys.argv[0])
PRAGMA_NOCOVER = '#pragma NO COVER'
rx_blank = re.compile('^\\s*(#.*)?$')
class Ignore:
def __init__(self, modules = None, dirs = None):
if not modules:
pass
self._mods = []
if not dirs:
pass
self._dirs = []
self._dirs = map(os.path.normpath, self._dirs)
self._ignore = {
'<string>': 1 }
def names(self, filename, modulename):
if self._ignore.has_key(modulename):
return self._ignore[modulename]
for mod in self._mods:
if mod == modulename:
self._ignore[modulename] = 1
return 1
n = len(mod)
if mod == modulename[:n] and modulename[n] == '.':
self._ignore[modulename] = 1
return 1
continue
if filename is None:
self._ignore[modulename] = 1
return 1
for d in self._dirs:
if filename.startswith(d + os.sep):
self._ignore[modulename] = 1
return 1
continue
self._ignore[modulename] = 0
return 0
def modname(path):
'''Return a plausible module name for the patch.'''
base = os.path.basename(path)
(filename, ext) = os.path.splitext(base)
return filename
def fullmodname(path):
'''Return a plausible module name for the path.'''
longest = ''
for dir in sys.path:
if path.startswith(dir) and path[len(dir)] == os.path.sep: